[PATCH 05/10] handle dlsym error on device library
authorAndreas Beckmann <anbe@debian.org>
Fri, 5 Feb 2021 15:01:50 +0000 (16:01 +0100)
committerAndreas Beckmann <anbe@debian.org>
Tue, 16 Feb 2021 10:00:57 +0000 (10:00 +0000)
Gbp-Pq: Name 0005-handle-dlsym-error-on-device-library.patch

lib/CL/devices/devices.c

index 77a1eaa516ae10bf8d478916571a83cfba8c79e3..9c1fc6fa48c53c8090389156d06881fe18acc67c 100644 (file)
@@ -595,11 +595,23 @@ pocl_init_devices ()
             {
               pocl_devices_init_ops[i] = (init_device_ops)dlsym (
                   pocl_device_handles[i], init_device_ops_name);
-              pocl_devices_init_ops[i](&pocl_device_ops[i]);
+              if (pocl_devices_init_ops[i] != NULL)
+                {
+                  pocl_devices_init_ops[i](&pocl_device_ops[i]);
+                }
+              else
+                {
+                  POCL_MSG_ERR ("Loading symbol %s from %s failed: %s\n",
+                                init_device_ops_name, device_library,
+                                dlerror ());
+                  device_count[i] = 0;
+                  continue;
+                }
             }
           else
             {
-              POCL_MSG_WARN ("Loading %s failed.\n", device_library);
+              POCL_MSG_WARN ("Loading %s failed: %s\n", device_library,
+                             dlerror ());
               device_count[i] = 0;
               continue;
             }